import jwt from 'jsonwebtoken';

export const secretkey = 'workflow';

export const sign = (data = {}) => {
  return jwt.sign(data, secretkey, {
    expiresIn: 60 * 60, // 秒 * 分
  });
};

export const verify = async (authorization) => {
  return new Promise((resolve, reject) => {
    let token = '';
    if (authorization.includes('Bearer')) {
      token = authorization.replace('Bearer ', '');
    } else {
      token = authorization;
    }
    const res = jwt.verify(token, secretkey);
    console.log(res, 11);
  });
};
